package com.example.controller;

import com.example.service.LockSupportExampleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/lock/support/example")
public class LockSupportExampleController {

    private final LockSupportExampleService service;

    public LockSupportExampleController(LockSupportExampleService service) {
        this.service = service;
    }

    @GetMapping("/park-thread")
    public String parkThread() {
        new Thread(service::parkThread).start();
        return "线程已挂起";
    }

    @GetMapping("/unpark-thread")
    public String unparkThread() {
        service.unparkThread();
        return "线程已唤醒";
    }
}
